package newtank.view.operate;

import lombok.Getter;
import lombok.Setter;
import newtank.TankClientFrame;
import newtank.view.TankDrawingCloth;

import java.awt.event.KeyListener;

/**
 * @author lijiahao
 * @since 2022/3/8
 */
public abstract class AbstractOperatorHandler implements OperatorHandler, KeyListener, Runnable{

    @Setter
    @Getter
    protected TankDrawingCloth tankDrawingCloth;

    @Setter
    protected TankClientFrame tankClientFrame;

    protected ThreadLocal<String> handleCode;

    protected void handleCodeInit() {
        if(handleCode == null) {
            handleCode = new ThreadLocal<>();
        }
    }

    protected void handleCodeRemove() {
        if(handleCode == null) {
            return;
        }
        handleCode.remove();
    }


    /**
     * 全部渲染
     */
    public void repaint() {
        tankDrawingCloth.repaint();
    }

}
